<?php

/*
 * -------------------------------------
 * www.dlancedu.com | Jaisiel Delance
 * framework mvc basico
 * Controller.php
 * -------------------------------------
 * Cristhian Boujon
 */

abstract class Controller extends BaseController {

    protected $loggin_type;

    /**
     * This method is called before call any other method
     */
    function before_load() {
//        update_db();
        if (!$this->is_logged()):
            $this->redirect_to($this->loggin_type(), 'index');
        else:
            $this->set('cerrar_session', 'Cerrar sesion');
        endif;
    }

    protected function is_logged() {
        return (Session::get('loggin_type')) ? true : false;
    }

    // $user Puede ser un afiliado o un admin.
    protected function loggin($user) {
        Session::set('loggin_type', $this->loggin_type());
        Session::set_object('user', $user);
    }
    
    protected function loggin_type(){
        return $this->loggin_type;
    }

}

?>
